import pandas as pd

csv_file = "../../../res/property-data.csv"
df = pd.read_csv(csv_file)

# 1.为空判断
print(df["NUM_BEDROOMS"])
print(df["NUM_BEDROOMS"].isnull())  # 检测是否为空

# 2.丢弃
new_df = df.dropna()  # 丢弃所有包含 空数据的行
print(new_df)

dropna_col_df = df.dropna(subset=["ST_NUM"])  # 丢弃列["ST_NUM"] 空数据的行
print(dropna_col_df)

# 3.填充
# 列空数据-填充
st_mean = df["ST_NUM"].mean()
df["ST_NUM"].fillna(st_mean, inplace=True)
print(df)

